<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <div>
      <p>clicked: {{ count }} times, count is {{ oddOrEven2 }}</p>
      <button @click="increment">+</button>
      <button @click="decrement">-</button>
      <button @click="incrementIfOdd">increment if odd</button>
      <button @click="incrementAsync">increment async</button>
    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
export default {
  name: "Demo1",
  props: {
    msg: String,
  },
  computed: mapGetters({
    // 名称不一样
    oddOrEven2: "oddOrEven",
    count: "count",
  }),
  // 名称一样
  methods: mapActions([
    "increment",
    "decrement",
    "incrementIfOdd",
    "incrementAsync",
  ]),
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
